package com.meixiang.adapter.myFundAdapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.meixiang.R;
import com.meixiang.entity.fund.FundInfoBean;
import com.meixiang.entity.shopping.MallMainGoodsEntity;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 我的基金 --其他推荐
 * author:xyj
 */
public class FundListOtherClassAdapter extends com.meixiang.recyclerview.RecyclerAdapter<FundListOtherClassAdapter.ViewHolder> {
    private Context mContext;
    private List<FundInfoBean> mRankInfosBean;

    public FundListOtherClassAdapter(Context context) {
        this.mContext = context;
    }

    /**
     * 刷新数据
     */
    public void refreshData(List<FundInfoBean> list) {
        mRankInfosBean = list;
        notifyDataSetChanged();
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_fund_list_fragment_item_other, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, final int position) {
        FundInfoBean rankInfosBean = mRankInfosBean.get(position);
        holder.tv_fund_other_name.setText(rankInfosBean.getFund_name());
        holder.tv_fund_other_id.setText(rankInfosBean.getFund_id());
        holder.tv_fund_other_nav.setText(rankInfosBean.getNav());
        holder.tv_fund_other_rate.setText(rankInfosBean.getRate());
        holder.tv_fund_other_cnt.setText(rankInfosBean.getCnt());
        holder.tv_other_fund_fee.setText(rankInfosBean.getFund_fee());
    }

    @Override
    public int getItemCount() {
        return mRankInfosBean ==null?0:mRankInfosBean.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.tv_fund_other_name)
        TextView tv_fund_other_name;
        @Bind(R.id.tv_fund_other_id)
        TextView tv_fund_other_id;
        @Bind(R.id.tv_fund_other_nav)
        TextView tv_fund_other_nav;
        @Bind(R.id.tv_fund_other_cnt)
        TextView tv_fund_other_cnt;
        @Bind(R.id.tv_fund_other_rate)
        TextView tv_fund_other_rate;
        @Bind(R.id.tv_other_fund_fee)
        TextView tv_other_fund_fee;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

}
